package eu.ec.ellipcis.integration.ws.endpoint;

import java.util.Map;

import javax.xml.transform.dom.DOMSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.stereotype.Component;

import eu.ec.ellipcis.integration.ws.policy.XmlValidationPolicy;

//@Component
public class XmlValidationServiceEndpoint {

    /* ---- Constants ---- */

    /* ---- Instance Variables ---- */

    @Autowired
    private Map<String, XmlValidationPolicy> xmlValidationPolicyMap = null;

    /* ---- Constructors ---- */

    /* ---- Business Methods ---- */

    @ServiceActivator
    public Message<?> handleRequest(Message<?> message) throws Exception {
        MessageHeaders messageHeaders = message.getHeaders();
        (xmlValidationPolicyMap.get("ticketRequest")).validate((DOMSource)message.getPayload());
        return message;
    }


    /* ---- Getters and Setters ---- */

    public Map<String, XmlValidationPolicy> getXmlValidationPolicyMap() {
        return xmlValidationPolicyMap;
    }


    public void setXmlValidationPolicyMap(
            Map<String, XmlValidationPolicy> xmlValidationPolicyMap) {
        this.xmlValidationPolicyMap = xmlValidationPolicyMap;
    }
}

